@elice/material-quiz 1.221217.0 → 1.221228.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +104 -128
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.d.ts +1 -0
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +212 -119
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +56 -143
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.d.ts +8 -0
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +144 -0
- package/cjs/components/material-quiz-edit/utils/editValue.js +7 -2
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +106 -130
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.d.ts +1 -0
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +212 -120
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +59 -146
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.d.ts +8 -0
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +136 -0
- package/es/components/material-quiz-edit/utils/editValue.js +3 -2
- package/package.json +4 -4
|
@@ -18,28 +18,21 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
18
18
|
var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
|
|
19
19
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
20
20
|
|
|
21
|
-
const OPTION_CONTENT_WIDTH = 205;
|
|
22
|
-
const OPTION_GROUP_WIDTH = 180;
|
|
23
|
-
const MIN_OPTION_INFO_COUNT = 2;
|
|
24
21
|
const MAX_OPTION_INFO_COUNT = 20;
|
|
25
|
-
const StyledSortableList = styled__default["default"].
|
|
22
|
+
const StyledSortableList = styled__default["default"].div.withConfig({
|
|
26
23
|
componentId: "sc-14yoda7-0"
|
|
27
24
|
})(["margin:1rem 0;padding:0;"]);
|
|
28
|
-
const StyledSortableListItemWrapper = styled__default["default"].li.withConfig({
|
|
29
|
-
componentId: "sc-14yoda7-1"
|
|
30
|
-
})(["display:flex;flex-direction:column;width:100%;&:not(:last-child){margin-bottom:0.5rem;}"]);
|
|
31
25
|
const StyledOptionTitle = styled__default["default"].div.withConfig({
|
|
32
|
-
componentId: "sc-14yoda7-
|
|
33
|
-
})(["display:flex;width:calc(100% - 2rem);"]); //
|
|
26
|
+
componentId: "sc-14yoda7-1"
|
|
27
|
+
})(["display:flex;width:calc(100% - 2rem - 1.5rem);"]); //
|
|
34
28
|
//
|
|
35
29
|
//
|
|
36
30
|
|
|
37
|
-
const
|
|
31
|
+
const OptionGroupAnswerInfo = () => {
|
|
38
32
|
const intl = reactIntl.useIntl();
|
|
39
33
|
const {
|
|
40
|
-
|
|
41
|
-
watch
|
|
42
|
-
setValue
|
|
34
|
+
setValue,
|
|
35
|
+
watch
|
|
43
36
|
} = reactHookForm.useFormContext();
|
|
44
37
|
const {
|
|
45
38
|
append: appendOptionInfoFieldItem,
|
|
@@ -49,10 +42,9 @@ const OptionGroupAnswerList = () => {
|
|
|
49
42
|
keyName: 'id',
|
|
50
43
|
shouldUnregister: true
|
|
51
44
|
});
|
|
52
|
-
const
|
|
45
|
+
const watchedOptions = watch('options');
|
|
53
46
|
const watchedAnswerInfo = watch('answerInfo');
|
|
54
|
-
const
|
|
55
|
-
const isMaximumOptions = (optionInfoFields === null || optionInfoFields === void 0 ? void 0 : optionInfoFields.length) >= MAX_OPTION_INFO_COUNT;
|
|
47
|
+
const isMaximumOptions = (watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.length) >= MAX_OPTION_INFO_COUNT;
|
|
56
48
|
/**
|
|
57
49
|
*
|
|
58
50
|
*/
|
|
@@ -69,97 +61,12 @@ const OptionGroupAnswerList = () => {
|
|
|
69
61
|
const recalculationAnswerList = cloneAnswerList.map(answers => answers.map(answer => answer > index ? answer - 1 : answer));
|
|
70
62
|
removeOptionInfoFieldItem(index);
|
|
71
63
|
setValue('answerInfo', recalculationAnswerList);
|
|
72
|
-
};
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (!checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(StyledSortableList, null, optionInfoFields === null || optionInfoFields === void 0 ? void 0 : optionInfoFields.map((option, index) => {
|
|
82
|
-
var _a, _b, _c, _d;
|
|
83
|
-
|
|
84
|
-
const errorMessage = (_d = (_c = (_b = (_a = formState.errors) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b[index]) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.message;
|
|
85
|
-
return React__default["default"].createElement(StyledSortableListItemWrapper, {
|
|
86
|
-
key: option.id
|
|
87
|
-
}, React__default["default"].createElement(blocks.Flex, {
|
|
88
|
-
align: "center",
|
|
89
|
-
width: "100%"
|
|
90
|
-
}, React__default["default"].createElement(OptionGroupAnswerListItem, {
|
|
91
|
-
optionId: index
|
|
92
|
-
}), React__default["default"].createElement(blocks.Hspace, {
|
|
93
|
-
width: 0.5
|
|
94
|
-
}), React__default["default"].createElement(blocks.Tooltip, {
|
|
95
|
-
title: isMinimumOptions ? intl.formatMessage({
|
|
96
|
-
id: 'answer.option.tooltip.minDisabled'
|
|
97
|
-
}) : undefined,
|
|
98
|
-
placement: "top"
|
|
99
|
-
}, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.IconButton, {
|
|
100
|
-
transparent: true,
|
|
101
|
-
icon: icons.eilMathsignMultiplyBasic,
|
|
102
|
-
role: "gray6",
|
|
103
|
-
size: "micro",
|
|
104
|
-
border: false,
|
|
105
|
-
disabled: isMinimumOptions,
|
|
106
|
-
onClick: () => handleRemoveItem(index)
|
|
107
|
-
})))), errorMessage ? React__default["default"].createElement(blocks.Text, {
|
|
108
|
-
size: "small",
|
|
109
|
-
role: "danger"
|
|
110
|
-
}, errorMessage) : null);
|
|
111
|
-
})), React__default["default"].createElement(blocks.Tooltip, {
|
|
112
|
-
title: isMaximumOptions ? intl.formatMessage({
|
|
113
|
-
id: 'answer.option.tooltip.maxDisabled'
|
|
114
|
-
}) : undefined,
|
|
115
|
-
placement: "top"
|
|
116
|
-
}, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.Button, {
|
|
117
|
-
borderDashed: true,
|
|
118
|
-
block: true,
|
|
119
|
-
transparent: true,
|
|
120
|
-
disabled: isMaximumOptions,
|
|
121
|
-
icon: React__default["default"].createElement(blocks.Icon, {
|
|
122
|
-
icon: icons.eilMathsignAddBasic
|
|
123
|
-
}),
|
|
124
|
-
onClick: () => appendOptionInfoFieldItem({
|
|
125
|
-
id: randomId.createRandomId(),
|
|
126
|
-
title: '',
|
|
127
|
-
content: ''
|
|
128
|
-
})
|
|
129
|
-
}, intl.formatMessage({
|
|
130
|
-
id: 'answer.option.addButton'
|
|
131
|
-
})))), React__default["default"].createElement(blocks.Vspace, {
|
|
132
|
-
height: 0.5
|
|
133
|
-
}), React__default["default"].createElement(blocks.StatusText, {
|
|
134
|
-
role: "description"
|
|
135
|
-
}, intl.formatMessage({
|
|
136
|
-
id: 'answer.option.file.description.imageSize'
|
|
137
|
-
})), React__default["default"].createElement(blocks.StatusText, {
|
|
138
|
-
role: "description"
|
|
139
|
-
}, intl.formatMessage({
|
|
140
|
-
id: 'answer.option.file.description.fileSize'
|
|
141
|
-
})), React__default["default"].createElement(blocks.StatusText, {
|
|
142
|
-
role: "description"
|
|
143
|
-
}, intl.formatMessage({
|
|
144
|
-
id: 'answer.option.file.description.extension'
|
|
145
|
-
})));
|
|
146
|
-
}; //
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const OptionGroupAnswerInfo = () => {
|
|
152
|
-
const intl = reactIntl.useIntl();
|
|
153
|
-
const {
|
|
154
|
-
setValue,
|
|
155
|
-
watch
|
|
156
|
-
} = reactHookForm.useFormContext();
|
|
157
|
-
const watchedOptions = watch('options');
|
|
158
|
-
const watchedAnswerInfo = watch('answerInfo');
|
|
64
|
+
};
|
|
159
65
|
/**
|
|
160
66
|
*
|
|
161
67
|
*/
|
|
162
68
|
|
|
69
|
+
|
|
163
70
|
const onSortEnd = ({
|
|
164
71
|
oldIndex,
|
|
165
72
|
newIndex
|
|
@@ -175,38 +82,107 @@ const OptionGroupAnswerInfo = () => {
|
|
|
175
82
|
setValue('options', reactSortableHoc.arrayMove(watchedOptions, oldIndex, newIndex), {
|
|
176
83
|
shouldDirty: true
|
|
177
84
|
});
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
const renderAnswerTitle = () => {
|
|
92
|
+
return React__default["default"].createElement(StyledOptionTitle, null, React__default["default"].createElement(blocks.Flex, {
|
|
93
|
+
width: "33.3%",
|
|
94
|
+
auto: true
|
|
95
|
+
}, React__default["default"].createElement(blocks.Text, {
|
|
96
|
+
size: "small",
|
|
97
|
+
bold: true
|
|
98
|
+
}, intl.formatMessage({
|
|
99
|
+
id: 'answer.option.title.text'
|
|
100
|
+
}))), React__default["default"].createElement(blocks.Flex, {
|
|
101
|
+
width: "33.3%"
|
|
102
|
+
}, React__default["default"].createElement(blocks.Text, {
|
|
103
|
+
size: "small",
|
|
104
|
+
bold: true
|
|
105
|
+
}, intl.formatMessage({
|
|
106
|
+
id: 'answer.option.title.file'
|
|
107
|
+
}))), React__default["default"].createElement(blocks.Flex, {
|
|
108
|
+
width: "calc(33.3% - 1.5rem)"
|
|
109
|
+
}, React__default["default"].createElement(blocks.Text, {
|
|
110
|
+
size: "small",
|
|
111
|
+
bold: true
|
|
112
|
+
}, intl.formatMessage({
|
|
113
|
+
id: 'answer.option.title.group'
|
|
114
|
+
}))));
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const renderAnswerOptionList = () => {
|
|
122
|
+
return React__default["default"].createElement(blocks.SortableListGroup, {
|
|
123
|
+
onSortEnd: onSortEnd,
|
|
124
|
+
useDragHandle: true
|
|
125
|
+
}, React__default["default"].createElement(StyledSortableList, null, watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map((option, index) => React__default["default"].createElement(OptionGroupAnswerListItem, {
|
|
126
|
+
key: option.id,
|
|
127
|
+
optionId: index,
|
|
128
|
+
onRemoveItem: () => handleRemoveItem(index)
|
|
129
|
+
}))));
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
const renderAnswerOptionAddButton = () => {
|
|
137
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(blocks.Tooltip, {
|
|
138
|
+
title: isMaximumOptions ? intl.formatMessage({
|
|
139
|
+
id: 'answer.option.tooltip.maxDisabled'
|
|
140
|
+
}) : undefined,
|
|
141
|
+
placement: "top"
|
|
142
|
+
}, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.Button, {
|
|
143
|
+
borderDashed: true,
|
|
144
|
+
block: true,
|
|
145
|
+
transparent: true,
|
|
146
|
+
disabled: isMaximumOptions,
|
|
147
|
+
icon: React__default["default"].createElement(blocks.Icon, {
|
|
148
|
+
icon: icons.eilMathsignAddBasic
|
|
149
|
+
}),
|
|
150
|
+
onClick: () => appendOptionInfoFieldItem({
|
|
151
|
+
id: randomId.createRandomId(),
|
|
152
|
+
title: '',
|
|
153
|
+
content: ''
|
|
154
|
+
})
|
|
155
|
+
}, intl.formatMessage({
|
|
156
|
+
id: 'answer.option.addButton'
|
|
157
|
+
})))), React__default["default"].createElement(blocks.Vspace, {
|
|
158
|
+
height: 0.5
|
|
159
|
+
}), React__default["default"].createElement(blocks.Flex, {
|
|
160
|
+
column: true
|
|
161
|
+
}, React__default["default"].createElement(blocks.StatusText, {
|
|
162
|
+
role: "description"
|
|
163
|
+
}, intl.formatMessage({
|
|
164
|
+
id: 'answer.option.file.description.imageSize'
|
|
165
|
+
})), React__default["default"].createElement(blocks.StatusText, {
|
|
166
|
+
role: "description"
|
|
167
|
+
}, intl.formatMessage({
|
|
168
|
+
id: 'answer.option.file.description.fileSize'
|
|
169
|
+
})), React__default["default"].createElement(blocks.StatusText, {
|
|
170
|
+
role: "description"
|
|
171
|
+
}, intl.formatMessage({
|
|
172
|
+
id: 'answer.option.file.description.extension'
|
|
173
|
+
}))));
|
|
178
174
|
}; //
|
|
179
175
|
//
|
|
180
176
|
//
|
|
181
177
|
|
|
182
178
|
|
|
179
|
+
if (!checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
183
|
return React__default["default"].createElement(blocks.Flex, {
|
|
184
184
|
column: true
|
|
185
|
-
},
|
|
186
|
-
auto: true
|
|
187
|
-
}, React__default["default"].createElement(blocks.Text, {
|
|
188
|
-
size: "small",
|
|
189
|
-
bold: true
|
|
190
|
-
}, intl.formatMessage({
|
|
191
|
-
id: 'answer.option.title.text'
|
|
192
|
-
}))), React__default["default"].createElement(blocks.Flex, {
|
|
193
|
-
width: `${OPTION_CONTENT_WIDTH}px`
|
|
194
|
-
}, React__default["default"].createElement(blocks.Text, {
|
|
195
|
-
size: "small",
|
|
196
|
-
bold: true
|
|
197
|
-
}, intl.formatMessage({
|
|
198
|
-
id: 'answer.option.title.file'
|
|
199
|
-
}))), React__default["default"].createElement(blocks.Flex, {
|
|
200
|
-
width: `${OPTION_GROUP_WIDTH}px`
|
|
201
|
-
}, React__default["default"].createElement(blocks.Text, {
|
|
202
|
-
size: "small",
|
|
203
|
-
bold: true
|
|
204
|
-
}, intl.formatMessage({
|
|
205
|
-
id: 'answer.option.title.group'
|
|
206
|
-
})))), React__default["default"].createElement(blocks.SortableListGroup, {
|
|
207
|
-
onSortEnd: onSortEnd,
|
|
208
|
-
useDragHandle: true
|
|
209
|
-
}, React__default["default"].createElement(OptionGroupAnswerList, null)));
|
|
185
|
+
}, renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton());
|
|
210
186
|
};
|
|
211
187
|
|
|
212
188
|
module.exports = OptionGroupAnswerInfo;
|